<!-- src/resources/templates/layout/layout.html -->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="head_c(title)">
    <meta charset="UTF-8">
    <title th:text="${title}">Default Title</title>
    <style>
        /* 添加自定义样式 */
        body {
            width: 100%;
            height: 100%;
        }
    </style>
    <script>
        window.addEventListener("load", function() {
            setTimeout(function() {
                document.querySelector('body').classList.add('loaded');
            }, 300);
        });
    </script>
    <!-- Favicon -->
    <link rel="icon" th:href="@{/static/img/favicon.ico}" type="image/png">
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/static/css/all.min.css}">
    <!-- Quick CSS -->
    <link rel="stylesheet" th:href="@{/static/css/quick-website.css}" id="stylesheet">
    <!-- Core JS  -->
    <script type="text/javascript" th:src="@{/static/js/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/bootstrap.bundle.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/svg-injector.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/feather.min.js}"></script>
    <!-- Quick JS -->
    <script type="text/javascript" th:src="@{/static/js/quick-website.js}"></script>
    <!-- Feather Icons -->
    <script>

    </script>

</head>
<body>

    <!-- 引入导航栏 -->
    <div th:fragment="nav" th:insert="~{fragments/navbar :: nav}"></div>

    <section class="slice py-7">

    </section>

    <script th:fragment="navjs">
        // 头像下拉框
        function is_logged_in() {
            $.get('/users/api/is_login', function(data) {
                console.log(data)
                if (data.msg === 'Online') {
                    // 用户已登录
                    $('#userDropdownMenu').html(`
                        <a class="dropdown-item" href="/users/update">账户管理</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item logoutLink" href="/logout">注销</a>
                    `);
                } else{
                    // 用户未登录
                    $('#userDropdownMenu').html(`
                        <a class="dropdown-item loginLink" href="/users/login">登录</a>
                        <a class="dropdown-item registerLink" href="/users/register">注册</a>
                    `);
                }
            });
        }

        $(function(){
            is_logged_in();
        })
    </script>

</body>
</html>